<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8">
    <title>{{ title }}</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>

    <script rel="stylesheet" href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css"></script>

  
<script src="https://cdn.jsdelivr.net/npm/wangeditor@latest/dist/wangEditor.min.js"></script>


  </head>
  <body>

    <div class="container">


      <div class="row clearfix">
        <div class="col-md-12 column">
          <nav class="navbar navbar-default navbar-inverse" role="navigation">
            <div class="navbar-header">
              <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span></button>
              <a class="navbar-brand" href="/">黄承武博客</a>
            </div>

            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
              {% if request.user.is_authenticated %}
                <ul class="nav navbar-nav navbar-right">
                  <li>
                    <a href="{% url  'addArticle' %}">写文章</a>
                  </li>
                  <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ request.user}}
                      <strong class="caret"></strong>
                    </a>
                    <ul class="dropdown-menu">
                      <li>
                        <a href="{% url  'userinfo' %}">个人信息</a>
                      </li>
                      <li>
                        <a href="{% url  'ArticleAdmin' %}">文章管理</a>
                      </li>
                      <li>
                        <a href="{% url  'upPwd' %}">密码修改</a>
                      </li>

                      <li class="divider"></li>
                      <li>
                        <a href="{% url 'userlogout' %}">注销</a>
                      </li>

                    </ul>
                  </li>

                </ul>

              {% else %}

                <ul class="nav navbar-nav navbar-right">
                  <li>
                    <a   data-toggle="modal" data-target="#register">注册</a>
                  </li>
                  <li>
                    <a href="" data-toggle="modal" data-target="#userlogin">登录</a>
                  </li>
                </ul>

              {% endif %}

            </div>

          </nav>

          {% block mainbody %}{% endblock %}

          <div class="modal fade" id="userlogin" tabindex="-1" role="dialog" aria-labelledby="userloginLabel" aria-hidden="true">

            <div class="modal-dialog">

              {% csrf_token %}

              <div class="modal-content">
                <div class="modal-header">
                  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
					&times;
				</button>
                  <h4 class="modal-title" id="userloginLabel">
				用户登录
				</h4>
                </div>
                <div class="modal-body">

                  <form class="form-horizontal" action="{% url 'userlogin' %}"  method="post">

                    {% csrf_token %}

                    <div class="form-group">
                      <label for="firstname" class="col-sm-2 control-label">用户</label>
                      <div class="col-sm-10">
                        <input type="text" name="username"    class="form-control" id="firstname" 
				   placeholder="请输入名字">
                      </div>
                    </div>
                    <div class="form-group">
                      <label for="lastname" class="col-sm-2 control-label">密码</label>
                      <div class="col-sm-10">
                        <input type="text" name="password"   class="form-control" id="lastname" 
				   placeholder="请输入姓">
                      </div>
                    </div>
                    <div class="form-group ">
                      <div class="col-sm-offset-2 col-sm-10 ">
                        <button type="submit" class="btn btn-default"  >登录</button>
                      </div>
                    </div>
                  </form>

                </div>

              </div>

              <!-- /.modal-content -->
            </div>
            <!-- /.modal -->
          </div>

          <div class="modal fade" id="register" tabindex="-1" role="dialog" aria-labelledby="registerLabel" aria-hidden="true">
            <div class="modal-dialog">
              <div class="modal-content">
                <div class="modal-header">
                  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                  <h4 class="modal-title" id="registerLabel">用户注册</h4>
                </div>
                <div class="modal-body">
                  <form class="form-horizontal" action="{% url 'register' %}"  method="post">

                    {% csrf_token %}
                    <div class="form-group">
                      <label for="lastname" class="col-sm-2 control-label">邮箱</label>
                      <div class="col-sm-10">
                        <input type="email" name="email" class="form-control" id="lastname" 
				   placeholder="输入邮箱">
                      </div>
                    </div>
                    <div class="form-group">
                      <label for="firstname" class="col-sm-2 control-label">用户名</label>
                      <div class="col-sm-10">
                        <input type="text" name="username"   class="form-control" id="firstname" 
				   placeholder="请输入名字">
                      </div>
                    </div>

                    <div class="form-group">
                      <label for="lastname" class="col-sm-2 control-label">密码</label>
                      <div class="col-sm-10">
                        <input type="passwrold" name="password"  class="form-control" id="lastname" 
				  >
                      </div>
                    </div>

                    <div class="form-group ">
                      <div class="col-sm-offset-2 col-sm-10 ">
                        <button type="submit" class="btn btn-default">注册</button>
                      </div>

                    </div>
                  </form>

                </div>

              </div>
              <!-- /.modal-content -->
            </div>
            <!-- /.modal -->
          </div>

        </body>
      </html>